<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加客户</title>
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/lib/layui/css/layui.css" />
	</head>

	<body>
		<form class="layui-form" action="" style="margin: 10px 10px 0 10px;">
			<div class="layui-form-item">
				<label for="userId"class="layui-form-label">业务员</label>
				<div class="layui-input-inline">
					<select name="userId" lay-filter="aihao">
						<option value=""></option>
						[#list list as user]
						<option value="${user.userId}" [#if balance.userId==user.userId]selected[/#if]>${user.name}</option>
						[/#list]
					</select>
				</div>
			</div>
				<label class="layui-form-label">充值金额</label>
				<div class="layui-input-inline">
					<input id="balanceCount" type="text" name="balanceCount" placeholder="" autocomplete="off" class="layui-input" lay-verify="">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="demo1"><i class="layui-icon">&#x1005;</i>充值</button>
				</div>
			</div>
		</form>
	</body>
	<script src="${BASE_PATH}/static/lib/layui/layui.js"></script>
	<script>
		layui.use(['form', 'layedit', 'laydate', 'jquery', 'table'], function() {
			var form = layui.form,
				layer = layui.layer;
			var $ = layui.jquery;
			var table = layui.table;
			var laydate = layui.laydate;

			//出生日期
			laydate.render({
				elem: '#test1'
			});

			//自定义验证规则
			form.verify({
				yhUserName: function(value) {
					if(value.length < 1) {
						return '姓名不能为空';
					}
				},
				yhUserAdds: function(value) {
					if(value.length < 1) {
						return '家庭住址不能为空';
					}
				}
			});

			//监听提交
			form.on('submit(demo1)', function(data) {
				$.ajax({
					type: 'POST',
					url: '${BASE_PATH}/admin/balan/balan_ajax',
					data: data.field,
					success: function(res) {
						if(res.success == true) {
							alert(res.msg);
							parent.location.reload();
						} else {
							alert(res.msg);
							parent.location.reload();
						}
					}
				})
				return false;
			});
			
		});
	</script>

</html>